#include "showtoday.h"

ShowToday::ShowToday( QWidget *parent)
    : QWidget( parent)
{
    this->setMinimumSize(800,480);
    this->setMaximumSize(800,480);

    QDateTime time = QDateTime::currentDateTime();//获取系统现在的时间

    sysDate = new ShowLabel(this);
    sysDate->addFontSize(6);
    sysDate->setAlignment(Qt::AlignHCenter);
    sysDate->setGeometry(QRect(140,40,650,40));
    sysDate->setText(time.toString("yyyy年M月d日 dddd"));

    updateTime = new ShowLabel(this);
    updateTime->addFontSize(4);
    updateTime->setAlignment(Qt::AlignHCenter);
    updateTime->setGeometry(QRect(140,70,650,40));
    updateTime->setText(time.toString("yyyy年M月d日 dddd")+tr("更新"));


    //℃
    netTemp = new ShowLabel(this);
//    netTemp->addFontSize(32);//arm
    netTemp->addFontSize(35);//pc
//    netTemp->setGeometry(QRect(370, 130, 200, 200));//arm
    netTemp->setGeometry(QRect(320,90, 150, 150));//pc
    netTemp->setText(tr("7℃"));

    weatherIcon = new QLabel(this);
    weatherIcon->setGeometry(QRect(480, 120, 100, 90));
    weatherIcon->setPixmap(QPixmap(":/images/weathercn02/0.png"));
    weatherIcon->setScaledContents(true);


    weather = new ShowLabel(this);
    weather->addFontSize(10);
    weather->setGeometry(QRect(140, 230, 650, 40));
    weather->setAlignment(Qt::AlignHCenter);
    weather->setText(tr("10:30更新　　　多云　２-９℃"));


    //显示网络数据
    netData = new ShowLabel(this);
    netData->addFontSize(4);
    netData->setGeometry(QRect(140, 285, 650, 40));
    netData->setAlignment(Qt::AlignHCenter);
    netData->setText(tr("湿度 87%    北风 2级     PM2.5 66   轻度污染"));


    //显示室内数据
    insideData = new ShowLabel(this);
    insideData->addFontSize(6);
    insideData->setGeometry(QRect(140, 360, 650, 40));
    insideData->setAlignment(Qt::AlignHCenter);
    insideData->setText(tr("室内   温度 4℃  湿度 78%  PM2.5 66"));


}
void ShowToday::setInsideVal(QString value){

    insideData->setText(value);
}


void ShowToday::updateVal(QString *arr){

    sysDate->setText(arr[1]+tr(" ")+arr[2]);

    //更新时间
    updateTime->setText(arr[11].mid(11)+tr("更新"));

    //当前温度
    netTemp->setText(arr[4]+tr("℃"));

    //天气图标
    weatherIcon->setPixmap(QPixmap(":/images/weathercn02/"+arr[7]+".png"));

    //城市,天气情况
    weather->setText(arr[0]+tr("       ")+arr[3]+tr(" ")+arr[5]+tr("-")+arr[6]+tr("℃"));

    //显示湿度，风力，空气
    netData->setText(tr("湿度 ")+arr[8]+tr("     ")+arr[9]+arr[10]+tr("     PM2.5 ")+arr[13] +tr("  ") + arr[14]);

}

